package org.geektimes.context.servlet;

import org.geektimes.context.ComponentContext;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @Author: menglinggang
 * @Date: 2021-03-24
 * @Time: 2:03 下午
 */
public class ComponentInitializer implements ServletContextListener {

    private ComponentContext context;
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        context = new ComponentContext();
        context.init(servletContextEvent.getServletContext());
        servletContextEvent.getServletContext().log("############## : inject ServletConfigInitializer  contextInitialized");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        context.destroy();
        servletContextEvent.getServletContext().log("############## : inject ServletConfigInitializer  contextDestroyed");
    }
}
